<template>
	<view class="notice-detail">
		<view class="notice">
			<u-swiper @click="noticeDetail" height="160" :showTitle="true" imgMode="aspectFill" :radius="0"
				:list="noticeSwoperList" @change="change" keyName="imageSrc" :autoplay="false" circular></u-swiper>
		</view>
		<view class="box-notice" @click="showNoticeList">
			<view class="title">
				{{noticeSwoperList[index].title | titleFilter}}
			</view>
			<view class="show-more" @click="showNoticeList">
				查看更多
				<u-icon name="arrow-right" color="#7e757f" size="14">
				</u-icon>
			</view>
		</view>
	</view>


</template>

<script>
	export default {
		data() {
			return {
				noticeSwoperList: [{
					title: ''
				}],
				//公告改变时的小标
				index: 0
			}
		},
		filters: {
			titleFilter(value) {

				if (value.length > 10) {
					return value.substring(0, 10) + '...'
				}
				return value
			},
		},
		methods: {
			//公告改变
			change(res) {

				this.index = res.current
			},

			//获取展示公告
			getNoticeSwoperList() {
				this.$request({
					url: `${this.$baseUrl}/notice/queryRolling`,
					methods: 'GET',
				}).then(res => {
					this.noticeSwoperList = res.data
				})
			},

			//查看更多公告
			showNoticeList() {
				uni.navigateTo({
					url: '/pages/notice/notice?id=0'
				})

				/* this.VshowNoticeList = !this.VshowNoticeList
				this.noticeListHeight=this.noticeList.length * 50 */
			},
			//根据id去查看公告详情
			noticeDetail(index) {
				console.log(this.noticeSwoperList[index].id)
				uni.navigateTo({
					url: `/pages/noticeDetail/noticeDetail?id=${this.noticeSwoperList[index].id}`,
				})
			}
		},

		mounted() {
			this.getNoticeSwoperList();
		}
	}
</script>

<style lang="scss">
	.notice-detail {
		position: absolute;
		top: 110rpx;
		width: 686rpx;
		margin-left: 32rpx;
		margin-left: 32rpx;
		border-radius: 16rpx;
		.notice {
			border-radius: 16rpx;
			overflow: hidden;
			width: 100%;
		}
		.box-notice {
			width: 100%;
			height: 64rpx;
			border-radius: 16rpx;
			background-color:  rgba(240, 242, 245, 1);
			margin-top: 20rpx;
			display: flex;
			justify-content:space-between;
			align-items: center;
			.title {
				font-size: 24rpx;
				margin-left: 10rpx;
				height: 56rpx;
				line-height: 56rpx;
				border-radius: 16rpx;
				background-color: white;
				color: orange;
				padding: 0 10rpx;
			}
			.show-more {
				margin-right: 15rpx;
				color: #b0b0b0;
				display: flex;
			}
		}
	}
</style>
